{% extends "index.html" %}
{% block title %}自动安装系统{% endblock %}
{% block active_home %}class="active"{% endblock %}
{% block active_nav_home %}class="active"{% endblock %}
{% block body %}
<div class="container">
  <a href="#newtask" role="button" class="btn btn-primary" data-toggle="modal">新增任务</a>
  <div class="row">
    <!--等待队列 span6-->
    <div class="span12">
      <table class="table table-hover table-bordered">
          <thead>
              <!--<td align='center'>等待队列</td> -->
              <tr><th>MAC地址</th><th>当前状态</th><th>IP</th><th>password</th><th>时间</th><th>操作</th></tr>
          </thead>
          <tbody>
                {% for i in servers %}
                <tr>
                  <td><a onClick=taskinfo({{ i.id }})>{{ i.mac }}</td>
                  <td>{{ i.message }}</td>
                  <td>eth0: {{ i.eth0 }}<br>eth1: {{ i.eth1 }}</td>
                  <td>{{ i.password }}</td>
                  <td>{{ i.timestrap|date:"Y-m-d H:i" }}</td>
                  <td><a  onClick="return confirm('注意：确定要删除此条目吗？')" class="btn delete_btn" href="/kis_cobbler/delete?type=wait_task&id={{ i.id }}">删除</a> <a class="btn" href="/kis_cobbler/edit?id={{ i.id }}">修改</a></td>
                </tr>
                {% endfor %}
          </tbody>
      </table>
    </div>
  </div>
  <!--新增任务按钮-->
  <form id="form-add-datacenter" class="well form-horizontal" action="/kis_cobbler/home/" method='post'>
    {% csrf_token %}
      <div id="newtask" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h3 id="myModalLabel">新增任务</h3>
        </div>
        <div class="modal-body">
            <div class="control-group">
              <label class="control-label" for="inputcobberserver">IDC机房</label>
              <div class="controls">
                <select class='cobblerserver' check-type="required" data-placeholder="选择机房" name='cobbler_server_id'>
                  <option value=""></option> 
                  {% for cobbler in cobbler_server %}
                    <option value='{{ cobbler.id }}'>{{ cobbler.idc }}</option>
                  {% endfor %}
                </select>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="inputprofile">安装系统</label>
              <div class="controls">
                <select class='profile' check-type="required" data-placeholder="选择需要安装的系统" name='profile'>
                  <option value=""></option> 
                </select>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="inputmac">MAC地址</label>
              <div class="controls">
                <td><input type="text" name='mac' check-type="required" required-message="WARN:不能为空" placeholder="MAC地址"></td>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="inputeth0">eth0</label>
              <div class="controls">
                <td><input type="text" name='eth0' placeholder="eth0 IP"></td>
                <span class="help-block">格式: 1.1.1.1/255.255.255.0</span>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="inputeth1">eth1</label>
              <div class="controls">
                <td><input type="text" name='eth1' placeholder="eth1 IP"></td>
                <span class="help-block">格式: 1.1.1.1/255.255.255.0</span>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label" for="inputeth0">hostname</label>
              <div class="controls">
                <td><input type="text" name='hostname' placeholder="Hostname"></td>
              </div>
            </div>
        </div>
        <div class="modal-footer">
          <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
          <button class="btn btn-primary text-right" type="submit">保存配置</button>
        </div>
      </div>
  </form>
</div>
<div id="messagemodal" class="modal hide fade">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>任务详细</h3>
  </div>
  <div class="modal-body" id="messagebody">
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
  </div>
</div>
{% endblock %}